import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue' // 导入插件

export default ({ mode, command }) => {
  const env = loadEnv(mode, process.cwd());
  const { VITE_APP_BASE,VITE_BASE_URL } = env;
  return defineConfig({
    base: VITE_APP_BASE,
    server: {
      port: 8888,
      proxy: {
        '/api': {
          target: VITE_BASE_URL+'8100',
          changeOrigin: true,
          rewrite: path => path.replace(/^\/api/, ''),
        },
        '/cloudhis-custom': {
          target: VITE_BASE_URL+'8101',
          changeOrigin: true
        },
        '/cloudhis-insys': {
          target: VITE_BASE_URL+'8102',
          changeOrigin: true
        },
        '/cloudhis-outsys': {
          target: VITE_BASE_URL+'8103',
          changeOrigin: true
        },
        '/cloudhis-stock': {
          target: VITE_BASE_URL+'8104',
          changeOrigin: true
        },
        '/cloudhis-caresys': {
          target: VITE_BASE_URL+'8107',
          changeOrigin: true
        },
        '/cloudhis-ai': {
          target: 'http://192.168.0.201:8688',
          //target: VITE_BASE_URL+'8688',
          changeOrigin: true
        },
        // 皕杰报表服务器地址 目前暂时配置 本地服务器地址 如需201服务器地址请自行修改
        '/biosReport': {
          //target: VITE_BASE_URL+'8106',
          target: 'http://192.168.0.201:8106',
          changeOrigin: true
        },
      },
    },
    plugins: [vue()] // 注册插件（关键步骤）
  });
};
